import {
  GET_ABOUT_US,
  GET_OPEN_ID,
  GET_TEACHER_INFO,
  GET_USER_INFO,
  GET_VERSIONS,
  LOGIN_OUT,
  SET_PHONE,
  SET_PLANT,
  SET_TOKEN,
  UPDATE_USER_INFO
} from "../../mutation-types";

export default {
  [SET_PLANT](state, plant) {
    state.plant = plant;
  },
  [GET_OPEN_ID](state, open_id) {
    state.open_id = open_id;
  },
  [SET_PHONE](state, phone) {
    state.phone = phone;
    uni.setStorageSync("phone", phone);
  },

  [SET_TOKEN](state, token) {
    state.token = token;
    uni.setStorageSync("token", token);
  },

  [LOGIN_OUT](state) {
    state.userInfo = {};
    state.token = "";
    state.open_id = "";
    state.phone = "";
  },

  [GET_USER_INFO](state, userInfo) {
    state.userInfo = userInfo;
  },

  [UPDATE_USER_INFO](state, rest) {
    state.userInfo = { ...state.userInfo, ...rest };
  },

  [GET_VERSIONS](state, version) {
    state.version = version[0];
  },

  [GET_TEACHER_INFO](state, teacherInfo) {
    state.teacherInfo = teacherInfo;
  },

  [GET_ABOUT_US](state, data) {
    state.aboutUs = data;
  }
};
